package com.pospi.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.pospi.dto.GoodsDto;
import com.pospi.dto.OrderDto;
import com.pospi.pai.yunpos.R;
import com.pospi.pai.yunpos.report.SaleOrderBeen;
import com.pospi.pai.yunpos.report.SaleOrderDetailBeen;
import com.pospi.util.Sava_list_To_Json;

import java.util.List;

/**
 * Created by acer on 2018/8/7.
 */

public class OrderDialogAdapter extends BaseAdapter {
    private Context context;
    private List<SaleOrderDetailBeen> orderDtos;

    public OrderDialogAdapter(Context context, List<SaleOrderDetailBeen> orderDtos) {
        this.context = context;
        this.orderDtos = orderDtos;
    }

    @Override
    public int getCount() {
        return orderDtos.size();
    }

    @Override
    public Object getItem(int position) {
        return orderDtos.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if (convertView == null) {
            holder = new Holder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_syy_order_detail, null);
            holder.tv_item_code = convertView.findViewById(R.id.tv_item_code);
            holder.tv_item_name = convertView.findViewById(R.id.tv_item_name);
            holder.tv_item_sl = convertView.findViewById(R.id.tv_item_sl);
            holder.tv_item_xsj = convertView.findViewById(R.id.tv_item_xsj);
            holder.tv_item_je = convertView.findViewById(R.id.tv_item_je);
            holder.tv_item_zk = convertView.findViewById(R.id.tv_item_zk);
            convertView.setTag(holder);

        } else {
            holder = (Holder) convertView.getTag();
        }
        SaleOrderDetailBeen been = orderDtos.get(position);
        holder.tv_item_code.setText(been.getBarcode());
        holder.tv_item_name.setText(been.getName());
        holder.tv_item_sl.setText(been.getSl());
        holder.tv_item_xsj.setText(been.getXsj());
        holder.tv_item_je.setText(been.getXsjje());
        holder.tv_item_zk.setText(been.getZzk());
        return convertView;
    }
    class Holder{
        TextView tv_item_code;
        TextView tv_item_name;
        TextView tv_item_sl;
        TextView tv_item_xsj;
        TextView tv_item_je;
        TextView tv_item_zk;
    }
}
